package br.feevale.escalonador.view.tablemodel;

import java.util.ArrayList;
import java.util.List;

import javax.swing.table.AbstractTableModel;

import br.feevale.escalonador.domain.Processo;

@SuppressWarnings("serial")
public class ProcessoEsperaTableModel extends AbstractTableModel {

	private List<Processo> rows;
	private String[] columns = new String[] {"ID", "Nome", "Estado", "Tempo"};

	public ProcessoEsperaTableModel() {
		rows = new ArrayList<Processo>();
	}
	
	public ProcessoEsperaTableModel(List<Processo> processos) {
		rows = processos;
	}

	@Override
	public int getRowCount() {
		return rows.size();
	}

	@Override
	public int getColumnCount() {
		return columns.length;
	}

	@Override
	public String getColumnName(int columnIndex) {
		return columns[columnIndex];
	}

	@Override
	public Object getValueAt(int rowIndex, int columnIndex) {
		Processo processo = rows.get(rowIndex);
		
		switch (columnIndex) {
			case 0 : return processo.getId();
			case 1 : return processo.getNome();
			case 2 : return processo.getStatus().getMeaning();
			case 3 : return processo.getTempoEspera();
		}
		
		return null;
	}

}
